import { _decorator, Component, find, Node, view } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('UiCenter')
export class UiCenter extends Component {
    start() {
        // const screenSize = view.getVisibleSize();
        // this.node.setWorldPosition(screenSize.width / 2, screenSize.height / 2, 0);
        const node =find("Canvas/player");
        //获取 node 坐标
        const pos = node.getWorldPosition();
        this.node.setWorldPosition(pos.x, pos.y, 0);

        // 设置为永远在最前面
        this.node.setSiblingIndex(9999);

    }
    onEnable() {
        console.log('onEnable - 节点变为激活状态时调用');
           const node =find("Canvas/player");
        //获取 node 坐标
        const pos = node.getWorldPosition();
        this.node.setWorldPosition(pos.x, pos.y, 0);
    }
    update(deltaTime: number) {
        // const screenSize = view.getVisibleSize();
        // this.node.setPosition(screenSize.width / 2, screenSize.height / 2, 0);
        
    }
}


